<template>
  <div>
    <el-page-header @back="()=>{this.$router.go(-1)}" content="我的稿件"></el-page-header>
    <el-container style="border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu>
          <el-submenu index="1">
            <template slot="title"> ● 官Q稿</template>
            <el-menu-item-group>
              <el-menu-item index="1-0" @click="Q(0)">全部</el-menu-item>
              <el-menu-item index="1-1" @click="Q(1)">一审中</el-menu-item>
              <el-menu-item index="1-2" @click="Q(2)">二审中</el-menu-item>
              <el-menu-item index="1-3" @click="Q(3)">已通过</el-menu-item>
              <el-menu-item index="1-4" @click="Q(4)">已发出</el-menu-item>
              <el-menu-item index="1-5" @click="Q(5)">驳回</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"> ● 新闻稿</template>
            <el-menu-item-group>
              <el-menu-item index="2-0" @click="News">全部</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-main>
        <div v-if="now==='q'">
          <div v-for="(index,key) in show">
            <ReadQ :id="index.id"></ReadQ>
            <el-divider></el-divider>
          </div>
        </div>
        <div v-if="now!=='q'">
          <div v-for="(index,key) in show">
            <readNews :id="index.id"></readNews>
            <el-divider></el-divider>
          </div>
        </div>
      </el-main>
    </el-container>
    </el-container>

  </div>
</template>

<script>
  import messageApi from "../../api/message.js"
  import ReadQ from "./ReadQ"
  import readNews from "./readNews"
  export default {
    data() {
      return {
        messageQ: null,
        messageNews: null,
        now: "q",
        show: null
      }
    },
    methods: {
      Q(type) {
        this.now = "q"
        if (type == 0) {
          this.show = this.messageQ;
        } else {
          this.show = this.messageQ.filter((x) => {
            return x.shen == type
          })
        }

      },
      News() {
        this.now = "news"
        this.show = this.messageNews;
      }
    },
    created() {
      messageApi.getMyMessage().then((res) => {
        this.messageQ = res.data
      })
      messageApi.getMyMessage(true).then((res) => {
        this.messageNews = res.data
      })
    },
    components: {
      ReadQ,
      readNews
    },
  }
</script>

<style>
</style>
